package com.hfut.jpoa.dao.impl;

import java.sql.SQLException;

import com.hfut.jpoa.common.exception.DaoException;
import com.hfut.jpoa.dao.UserRightDAO;
import com.hfut.jpoa.model.UserRight;
import com.hfut.jpoa.model.UserRightWithBLOBs;
import com.ibatis.sqlmap.client.SqlMapClient;

public class UserRightDAOImpl implements UserRightDAO {
    private SqlMapClient sqlMapClient;
    
    public int deleteByPrimaryKey(String id)
        throws DaoException {
        UserRight key = new UserRight();
        key.setId(id);
        int rows = 0;
        try {
            rows = sqlMapClient.delete("tb_sys_userright.ibatorgenerated_deleteByPrimaryKey", key);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rows;
    }
    
    public void insert(UserRightWithBLOBs record)
        throws DaoException {
        try {
            sqlMapClient.insert("tb_sys_userright.ibatorgenerated_insert", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    public void insertSelective(UserRightWithBLOBs record)
        throws DaoException {
        try {
            sqlMapClient.insert("tb_sys_userright.ibatorgenerated_insertSelective", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    public UserRightWithBLOBs selectByPrimaryKey(String id)
        throws DaoException {
        UserRight key = new UserRight();
        key.setId(id);
        UserRightWithBLOBs record = null;
        try {
            record = (UserRightWithBLOBs)sqlMapClient.queryForObject("tb_sys_userright.ibatorgenerated_selectByPrimaryKey", key);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return record;
    }
    
    public int updateByPrimaryKeySelective(UserRightWithBLOBs record)
        throws DaoException {
        int rows = 0;
        try {
            rows = sqlMapClient.update("tb_sys_userright.ibatorgenerated_updateByPrimaryKeySelective", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rows;
    }
    
    public int updateByPrimaryKey(UserRightWithBLOBs record)
        throws DaoException {
        int rows = 0;
        try {
            rows = sqlMapClient.update("tb_sys_userright.ibatorgenerated_updateByPrimaryKeyWithBLOBs", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rows;
    }
    
    public int updateByPrimaryKey(UserRight record)
        throws DaoException {
        int rows = 0;
        try {
            rows = sqlMapClient.update("tb_sys_userright.ibatorgenerated_updateByPrimaryKey", record);
        }
        catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return rows;
    }
    
    /**
    * @param 对sqlMapClient进行赋值
    */
    public void setSqlMapClient(SqlMapClient sqlMapClient) {
        this.sqlMapClient = sqlMapClient;
    }
}